import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SGuildWarehouseRecord } from "../../../../../Message/Game/SGuildWarehouseRecord";
import { DateParser } from "../../../../common/tools/DateParser";
import { ItemData } from "../../../resource/info/ItemData";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { EGuildWarehouseOper } from "../../../../../Message/Game/EGuildWarehouseOper";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
//class RecordRenderer
    
    export  class RecordRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            this._record = arg1 as SGuildWarehouseRecord;
            if (this._record) 
            {
                this._dateTxt.text = DateParser.parse(this._record.operDt, "M-d hh: mm");
                this._playerNameTxt.text = this._record.name;
                this._approverNameTxt.text = this._record.assignName;
                if (this._record.itemCode > 0) 
                {
                    loc1 = new ItemData(this._record.itemCode);
                    this._itemName = ItemsUtil.getItemName(loc1);
                }
                else 
                {
                    this._itemName = GameDefConfig.instance.getEPrictUnitName(this._record.unit);
                }
                this._itemNameTxt.htmlText = this._itemName;
                if (this._record.oper.value() == EGuildWarehouseOper._EGuildWarehouseIn || this._record.oper.value() == EGuildWarehouseOper._EGuildWarehouseMove) 
                {
                    this._operTxt.text = Language.getString(57269);
                    this._amountTxt.text = "+ " + this._record.amount.toString();
                }
                else if (this._record.oper.value() != EGuildWarehouseOper._EGuildWarehouseOut) 
                {
                    if (this._record.oper.value() != EGuildWarehouseOper._EGuildWarehouseSellIn) 
                    {
                        if (this._record.oper.value() == EGuildWarehouseOper._EGuildWarehouseSellOut) 
                        {
                            this._operTxt.text = Language.getString(57639);
                            this._amountTxt.text = "- " + this._record.amount.toString();
                        }
                    }
                    else 
                    {
                        this._operTxt.text = Language.getString(57639);
                        this._amountTxt.text = "+ " + this._record.amount.toString();
                    }
                }
                else 
                {
                    this._operTxt.text = Language.getString(57270);
                    this._amountTxt.text = "- " + this._record.amount.toString();
                }
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=5;
            this._dateTxt = ObjCreate.createTextField("", 10, loc1, 170, 20, this);
            this._playerNameTxt = ObjCreate.createTextField("", 85, loc1, 170, 20, this);
            this._playerNameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._approverNameTxt = ObjCreate.createTextField("", 180, loc1, 170, 20, this);
            this._approverNameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._itemNameTxt = ObjCreate.createTextField("", 260, loc1, 95, 20, this, GlobalStyle.textFormat6);
            this._itemNameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._amountTxt = ObjCreate.createTextField("", 362, loc1, 30, 20, this);
            this._amountTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._operTxt = ObjCreate.createTextField("", 413, loc1, 170, 20, this);
            ObjCreate.createBg(5, 30, 460, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal */ /* var */_dateTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_approverNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_amountTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_operTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_record: SGuildWarehouseRecord;

        /* internal */ /* var */_itemName: string;
    }
